﻿<style scoped>
  .layui-btn:hover {
  }
</style>
<!-- 正文开始 -->
<div class="layui-fluid" style="padding: 5px;">
    <div class="layui-card">
        <div class="layui-card-body" style="padding:0px;">
		<form id="modelBizLineForm" lay-filter="modelBizLineForm" class="layui-form model-form" style="padding:0px;">
			<input name="id" type="hidden"  id="markarLineId" value="#(bizLine?bizLine.id:'')" />
			<input name="sceneId" type="hidden"  value="#(sceneId)" /> 
			<input name="points" type="hidden" id="markarLinePoints"   />         
			<table class="formTable">
				<tr>
					<td>名称</td>
					<td colspan="2">
						<input id="BizLineName-input" name="name" value="#(bizLine?bizLine.name:'')" placeholder="" autocomplete="off"   type="text" class="layui-input" maxlength="50" lay-verType="tips" lay-verify="required" required/>
					</td>
				</tr>	
				<tr>
					<td>标识</td>
					<td colspan="2">
						<input name="code" placeholder="" value="#(bizLine?bizLine.code:'')"  autocomplete="off"   type="text" class="layui-input" maxlength="50"/>
					</td>
				</tr>	
				<tr>
					<td>样式</td>
					<td >
						<input id="styleName-input" name="styleName" value="#(bizLine?bizLine.styleName:'')"   readonly="readonly" placeholder="" autocomplete="off"   type="text" class="layui-input" maxlength="50"/>
						<input id="styleId-input" name="styleId" value="#(bizLine?bizLine.styleId:'')"   type="hidden" />
					</td>
					<td>
						<button class="layui-btn layui-btn-sm" id="selectStyleForBizLine">选择</button>
					</td>
				</tr>
				<tr>
					<td>序号:</td>
					<td colspan="2">
						<input name="sort" autocomplete="off"  value="#(bizLine?bizLine.sort:0)"   placeholder="请输入序号" type="number" class="layui-input" maxlength="20"  lay-verType="tips" lay-verify="required" required/>
					</td>
				</tr>
				<tr>
					<td colspan="3">
						<button class="layui-btn layui-btn-sm" lay-filter="submitBizLineForm" lay-submit>保存</button>
					</td>
				</tr>
			</table>	
			</form>		
        </div>
    </div>
    
			<table class="formTable">
				<tr>
					<td>名称</td>
					<td colspan="2">
						<input id="BizLineName-input" name="name" value="#(bizLine?bizLine.name:'')" placeholder="" autocomplete="off"   type="text" class="layui-input" maxlength="50" lay-verType="tips" lay-verify="required" required/>
					</td>
				</tr>	
				<tr>
					<td>标识</td>
					<td colspan="2">
						<input name="code" placeholder="" value="#(bizLine?bizLine.code:'')"  autocomplete="off"   type="text" class="layui-input" maxlength="50"/>
					</td>
				</tr>	
				<tr>
					<td>样式</td>
					<td >
						<input id="styleName-input" name="styleName" value="#(bizLine?bizLine.styleName:'')"   readonly="readonly" placeholder="" autocomplete="off"   type="text" class="layui-input" maxlength="50"/>
						<input id="styleId-input" name="styleId" value="#(bizLine?bizLine.styleId:'')"   type="hidden" />
					</td>
					<td>
						<button class="layui-btn layui-btn-sm" id="selectStyleForBizLine">选择</button>
					</td>
				</tr>
				<tr>
					<td>序号:</td>
					<td colspan="2">
						<input name="sort" autocomplete="off"  value="#(bizLine?bizLine.sort:0)"   placeholder="请输入序号" type="number" class="layui-input" maxlength="20"  lay-verType="tips" lay-verify="required" required/>
					</td>
				</tr>
				<tr>
					<td colspan="3">
						<button class="layui-btn layui-btn-sm" lay-filter="submitBizLineForm" lay-submit>保存</button>
					</td>
				</tr>
			</table>    
    
</div>


<script type="text/html" id="modelBizLineStyleScript">
	<div class="layui-card">
		<div class="layui-card-body">
                <div class="layui-form-item" style="margin-bottom: 0px">
                    <div class="layui-inline" style="float: right;margin-right: 0px;">
						<div class="layui-inline" style="padding-right: 0px;margin-right: 0px;">
							<label class="layui-form-label w-auto">场景</label>
							<div class="layui-input-inline mr0">
								<input name="name" class="layui-input" type="text" autocomplete="off"  placeholder="请输入样式名称"/>
							</div>
						</div>
						<div class="layui-inline" style="padding-right: 0px;margin-right: 0px;">
							<button class="layui-btn icon-btn" lay-filter="formSubSearchBizLineStyle" lay-submit>
								<i class="layui-icon">&#xe615;</i>查询
							</button>
							<button class="layui-btn icon-btn" id="selectBizLineStyleBtn">
								<i class="layui-icon">&#xe605;</i>确定
							</button>
						</div>					
					</div>
				</div>

			<table class="layui-table" id="tableStyleBizLine" lay-filter="tableStyleBizLine"></table>
		</div>
	</div>
</script>


<script src="#(ctx)/assets/plugins/zTree_v3/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="#(ctx)/assets/plugins/zTree_v3/js/jquery.ztree.core.js"></script>
<script type="text/javascript" src="#(ctx)/assets/plugins/zTree_v3/js/jquery.ztree.exedit.js"></script>

<!-- js部分 -->
<SCRIPT type="text/javascript">


layui.use(['layer','form','table'], function () {
    var $ = layui.jquery;
    var layer = layui.layer;
	var form =layui.form;
	var table =layui.table;
	var viewer=globe.viewer;
	
	var layerId='#(bizLine?bizLine.layerId:"")';
	
	var uniqueId=$("#markarLineId").val();
	viewer.entities.removeById(uniqueId);
	form.on('submit(submitBizLineForm)', function (data) {
	    layer.load(2);
        var formData={}; 
        for(var key in data.field){
        	formData['bizLine.'+key]=data.field[key];
        }
        var res = common_ajax.ajaxFunc("#(ctx)/biz/marker/line/save",formData, "json", null);
        layer.closeAll('loading');
        if (200==res.code) {
            layer.msg(res.message, {icon: 1});
            var data=res.data;
        	var zTree = $.fn.zTree.getZTreeObj("bizLayerTree")||sceneTree;
        	if(zTree){
        		var editNode =zTree.getNodeByParam("id",data.id);
        		if(editNode){
        			editNode.name=data.name;
        			zTree.updateNode(editNode);
        		}else{
        			var treeNode =zTree.getNodeByParam("id",data.layerId);
        			zTree.addNodes(treeNode?treeNode:null, {id:data.id, pId:data.layerId, name:data.name,type:'line'});
        		}
        	}       
        } else {
            layer.msg(res.message, {icon: 2});
        }
	    return false;
	});
	form.render(); 
	
	$('#selectStyleForBizLine').click(function () {
        layer.open({
            type: 1,
            title: '标绘线样式',
            content: $('#modelBizLineStyleScript').html(),
            area:'450px',
            offset: 't'	,
            success: function (layero, dIndex) {
           	 	$(layero).children('.layui-layer-content').css('overflow', 'visible');
                // 渲染表格
                var insTbForBizLineIcon = table.render({
                    elem: '#tableStyleBizLine',
                    url: '#(ctx)/biz/style/line/listData', 
                    page: true,
                    cellMinWidth: 100,
                    cols: [[
                        {type:'radio'},
                        {field: 'name', sort: false, title: '名称'},
                    ]]
                });
                
                // 搜索
                form.on('submit(formSubSearchBizLineStyle)', function (data) {
                	insTbForBizLineIcon.reload({where: data.field}, 'data');
                });
        		$('#selectBizLineStyleBtn').click(function () {
        			var checkStatus = table.checkStatus("tableStyleBizLine"); //获取选中行状态
			        var data = checkStatus.data;  //获取选中行数据
			        if(data && data.length>0){
 			        	$("#styleName-input").val(data[0].name);
			        	$("#styleId-input").val(data[0].id);
 			        	polyline=VFG.Util.getEntityForLine(data[0]);
			        	if(primitive){
			        		var uniqueId=$("#markarLineId").val();
			        		viewer.entities.removeById(uniqueId);
 			        		createLinePrimitive(viewer,{
								id:uniqueId,
								name:$('#BizLineName-input').val(),
							}); 
			        	} 
			        	layer.close(dIndex);
			        }else{
			        	layer.msg("请选择样式!!!", {icon: 3});
			        }
			        return false;
       			});
            }
        });
		return false;
	});
	

});
</SCRIPT>